<template>
    <div class="wrapper">
        <v-head></v-head>
        <v-sidebar></v-sidebar>
        <!-- 实现样式  -->
        <div class="content-box" :class="{'content-collapse':collapse}">
            <!--实现面包屑  保存的数组里面  访问点击时候的样式  -->

            <v-tags></v-tags>
            <!-- 动画 -->

            <div class="content">
                <transition name="move" mode="out-in">
                    <keep-alive :include="tagsList">
                        <router-view></router-view>
                    </keep-alive>
                </transition>
                <!-- 回到顶部 -->

                <el-backtop target=".content"></el-backtop>
            </div>
        </div>
    </div>
</template>

<script>
import vHead from './Header.vue'; //头部
import vSidebar from './Sidebar.vue'; //侧边栏
import vTags from './Tags.vue'; //标签 其他标签
// import echart from './echart.vue'    //Echart图标页
import bus from './bus';
export default {
    data() {
        return {
            tagsList: [],
            collapse: false //不显示
        };
    },
    components: {
        vHead,
        vSidebar,
        vTags,
    },
    created() {
        bus.$on('collapse-content', (msg) => {
            this.collapse = msg;
        });

        // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
        bus.$on('tags', (msg) => {
            let arr = [];
            for (let i = 0, len = msg.length; i < len; i++) {
                msg[i].name && arr.push(msg[i].name);
            }
            this.tagsList = arr;
        });
    }
};
</script>
